import store from '@/store'

const hasPermission = {}

hasPermission.install = function(Vue, options) {
  Vue.prototype.hasPermission = function(value) {
    const permission = store.getters && store.getters.permission
    if (value && value.length > 0) {
      return permission.includes(value)
    } else {
      throw new Error(`need permission! Like hasPermission("users_113_03")`)
    }
  }
}

export default hasPermission
